package com.lmf.annotation;

import com.lmf.annotation.bean.Person;
import com.lmf.annotation.config.MyConfig;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class ConfigTest_01 {

    //加载配置类，创建spring容器，并获取创建的注册类
    @Test
    public void configTest(){
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfig.class);
//        Person person = context.getBean("person", Person.class);
        Person person = context.getBean("student", Person.class);
        System.out.println(person);
        System.out.println("--------------------------------------");
        String[] beanDefinitionNames = context.getBeanDefinitionNames();
        for (String name : beanDefinitionNames) {
            System.out.println(name);
        }
    }
}
